package com.threeonemeeting.model;

import android.graphics.Bitmap;

import com.snda.lib.util.MiscHelper;

/**
 * 
 * @author zhangzhongqing 自定义的下载软件的保存信息
 */
public class DownloadInfo {

	public static final int DOWNLOAD_STATUS_RUNNING = 0; // 正在运行
	public static final int DOWNLOAD_STATUS_FINISHED = 1; // 已经下载完毕
	public static final int DOWNLOAD_STATUS_FAILED = 2; // 下载失败
	public static final int DOWNLOAD_STATUS_WAITINGWIFI = 3; // 等待WiFi下载
	public static final int DOWNLOAD_STATUS_CANCEL = 4; // 用户主动取消

	public int nCookie; // 对应的Task Cookie
	public String strAppKey = ""; // 应用的AppKey
	public String strFileName = ""; // 文件的下载名称
	public String strFileTitle = "";
	public Bitmap bitmap = null;

	public long nFileSize; // 下载文件的大小
	public long nFileDownloadedSize; // 已经下载的大小

	public String strFileUrl;
	public String strLocalPath; // 本地的保存目录
	public long nDownloadTime; // 下载开始的时间，会按照这个进行排序
	public int nStatus = DOWNLOAD_STATUS_FAILED; // 当前的下载状态，默认是尚未下载
	public boolean bWiFiDownload; // 是否是WiFi下载

	public int getPercent() {
		if (nFileSize == 0)
			return 0;

		return (int) ((nFileDownloadedSize * 100) / nFileSize);
	}
	
	public String getShowName() {
		if (MiscHelper.isEmail(strFileTitle) == false)
			return strFileTitle;

		return strFileName;
	}

}